<template>
  <div>
    <!-- 随机生成笑话 -->
    <h1>{{msg}}</h1>
    <!-- 点击事件，随机生成 -->
    <button @click="jokeChange">点击随机生成笑话</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg:"这里是笑话",
      jokeArr:['sdrtyuiopsdfghjkrftyuio','摄入体育和哦IP覆盖后人生如同一舍得让他','1234567891234567876543']
    }
  },
  methods:{
    // 生成随机笑话的函数
    jokeChange() {
      // 随机生成下标
      let index = parseInt(Math.random()*this.jokeArr.length)
      this.msg = this.jokeArr[index]
    }
  }
}
</script>

<style lang="scss" scoped>

</style>